<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* px转为em:现在40px(当然只要父容器是50px、60px都是) = 1em,我们需要将div下的p的字体缩小至父容器字体的一半，那么就需要将p的font-size设置为0.5em,如果设置为1那么就和上面父容器的font-size：40px一样了 */
        /* div {
            font-size: 40px;
            width: 7.5em;
            height: 7.5em;
            border: solid 2px black;
        }

        p {
            font-size: 0.5em;
            width: 7.5em;
            height: 7.5em;
            border: solid 2px blue;
            color: blue;
        }

        span {
            font-size: 0.5em;
            width: 7em;
            height: 6em;
            border: solid 1px red;
            display: block;
            color: red;
        } */

        /* 以font-size为例， */
        div {
            font-size: 4rem;
            /* 40px */
            width: 20rem;
            /* 200px */
            height: 20rem;
            border: solid 2px black;
        }

        p {
            font-size: 2rem;
            /* 20px */
            width: 10rem;
            height: 10rem;
            border: solid 1px blue;
            color: blue;
        }

        span {
            font-size: 1.5rem;
            width: 7rem;
            height: 6rem;
            border: solid 2px red;
            display: block;
            color: red;
        }
    </style>
</head>

<body>
    <div>
        父元素div
        <p>
            子元素p
            <span>孙元素span</span>
        </p>
    </div>
</body>

</html>